<script type="text/javascript" src="/javascripts/prototype.js"></script>
<script>
 function update_ur(u_id, r_id){
       new Ajax.Updater(
        "centerDiv",
        "/system/user_manage/ur_update/"+u_id+"&"+r_id ,
        {  method: 'get',
          asynchronous: true,
          evalScripts: true,
          parameters: 'authenticity_token=' + window._token  
        }
      );
     }
</script>
<%= javascript_include_tag :defaults %>
  <br />
<div  style="background-color:#FFFFF8;height:25px;width:200px">
          <font  color="red"><%=flash[:errors] %></font>
      </div>
  &nbsp;&nbsp;&nbsp;<a href="/system/user_manage/index">用户管理</a> >> 
  用户角色管理<br />
  <h4>用户列表:</h4>
   <div id="" style="margin-left : 15px;">
<table border="1"  width="900">
<% for user in @users %>
   <tr>
      <td width="120"><%=user.username%>
      
      </td>
       <td width="860"> 
          <%   user_role=UserRole.find(:all , :conditions => {:user_id=> user.id}) %>
          <% for role in Role.find(:all)%>
            <%   check=false
            for  ur  in  user_role 
              if  ur.role_id == role.id
                 check=true
             end
           end  %>
            <input type="checkbox" name="" onclick="update_ur(<%=user.id%>,<%=role.id%>);" 
            <%  if  check==true %>
              checked=true
            <% end %>
             ><%=role.name%></input>
             <% end %>
             </td>
             <td width="50px">
             &nbsp;&nbsp;<a onclick="return confirm('确定删除?');" href="/system/user_manage/destroy_user/<%=user.id%>">
      <font color="＃F756＊（">删除</font>
      </a>
             </td>
   </tr>
<% end %>
</table>
<%=will_paginate(@users ,:prev_label=>'上一页',:next_label=>'下一页',:separator=>" | ") %>
</div>

